package cn.itrip.biz.controller;

import cn.itrip.beans.dto.Dto;
import cn.itrip.beans.vo.OrderVo;
import cn.itrip.biz.service.ItripHotelOrderService;
import cn.itrip.common.DtoUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RequestMapping("/api")
@RestController
public class ItripHotelOrderController {

    @Resource
    private ItripHotelOrderService itripHotelOrderService;

    @ApiOperation(value = "根据条件查 询个人订单 列表，", httpMethod = "POST", protocols = "HTTP", produces = "application/json", response = Dto.class, notes = "查询常用联系人")
    @RequestMapping(value = "/hotelorder/getpersonalorderlist", method = RequestMethod.POST)
    public Dto getpersonalorderlisti(@RequestBody OrderVo orderVo){
        try {
            return itripHotelOrderService.selectOrderAll(orderVo);
        } catch (Exception e) {
            return DtoUtils.getExcetpionDto(e,"");
        }
    }
    @ApiOperation(value = "根据订单ID查看个人订单详情", httpMethod = "POST", protocols = "HTTP", produces = "application/json", response = Dto.class, notes = "查询常用联系人")
    @RequestMapping(value = "/hotelorder/getpersonalorderinfo/{orderId}", method = RequestMethod.GET)
    public Dto selectById(@PathVariable String orderId, HttpServletRequest request){
      //  itripHotelOrderService.dsq(orderId);
        try {
            return itripHotelOrderService.selectById(orderId);
        } catch (Exception e) {
            return DtoUtils.getExcetpionDto(e,"");
        }
    }

    @ApiOperation(value = "根据订单ID查看个人入住信息", httpMethod = "POST", protocols = "HTTP", produces = "application/json", response = Dto.class, notes = "查询常用联系人")
    @RequestMapping(value = "/hotelorder/getpersonalorderroominfo/{orderId}", method = RequestMethod.GET)
    public Dto getPersonalOrderRoomInfo(@PathVariable String orderId, HttpServletRequest request) throws Exception {
        try {
            return itripHotelOrderService.selectByKey(orderId);
        } catch (Exception e) {
            return DtoUtils.getExcetpionDto(e,"");
        }
    }
    //<editor-fold desc="根据订单ID获取订单信息">
    /**
     * 根据订单ID获取订单信息
     * 错误码：
     * 100533 : 没有查询到相应订单
     * 100534 : 系统异常
     * */
    @RequestMapping(value = "/hotelorder/queryOrderById/{orderId}", method = RequestMethod.GET, produces = "application/json")
    public Dto queryOrderById(@PathVariable String orderId, HttpServletRequest request) {
        try {
            return itripHotelOrderService.selectByKey(orderId);
        } catch (Exception e) {
            return DtoUtils.getExcetpionDto(e,"");
        }
    }
}

